<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="@{include} :: header"></head>

<style>
    .layui-form-item{
        margin-bottom: 8px;
    }
</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-row">
            <form class="layui-form layui-form-pane" id="signupForm">
                <input id="id" name="id" th:value="${question.id}" type="hidden" />
                <input id="surveyId" name="surveyId" th:value="${question.surveyId}" type="hidden" />
                <input id="section_count" name="section_count" th:value="${question.sectionsCount}" type="hidden" />
                <input id="section_now_index" name="section_now_index" th:value="${question.sectionsCount}" type="hidden" />
                <input id="answerSection" name="answerSection" value="" type="hidden" />
                <div class="layui-form-item">
                    <label class="layui-form-label">调查内容：</label>
                    <div class="layui-input-block">
                        <input id="question" name="question" th:value="${question.question}" class="layui-input" type="text">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">备注说明：</label>
                    <div class="layui-input-block">
                        <input id="remark" name="remark" th:value="${question.remark}" class="layui-input" type="text">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">问题类型：</label>
                    <div class="layui-input-block">
                        <select data-placeholder="--请选择--" name="questionType" id="questionType"
                                class="layui-input chosen-select" lay-filter="questionType">
                            <option value="0" th:selected="${question.questionType eq 0}">单选题</option>
                            <option value="2" th:selected="${question.questionType eq 2}">多选题</option>
                            <option value="1" th:selected="${question.questionType eq 1}">输入项</option>
                            <option value="3" th:selected="${question.questionType eq 3}">上传图片</option>
                        </select>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-block">
                        <select data-placeholder="--请选择--" name="state" id="state"
                                class="layui-input chosen-select">
                            <option value="0" th:selected="${question.state eq 0}">禁用</option>
                            <option value="1" th:selected="${question.state eq 1}">开启</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">是否必填：</label>
                    <div class="layui-input-block">
                        <select data-placeholder="--请选择--" name="isRequire" id="isRequire"
                                class="layui-input chosen-select">
                            <option value="1" th:selected="${question.isRequire eq 1}">必填</option>
                            <option value="0" th:selected="${question.isRequire eq 0}">非必填</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序索引：</label>
                    <div class="layui-input-block">
                        <input id="sort" name="sort" th:value="${question.sort}" class="layui-input" type="number">
                    </div>
                </div>


                <div id="divSections" th:classappend="${question.questionType == 0 || question.questionType == 2}  ? '' : 'layui-hide'" >
                    <div class="layui-form-item" th:each="section : ${question.sections}" th:id="${'div_value_' + section.index}">
                        <label class="layui-form-label" th:text="${'选项' + (section.index + 1)}"></label>
                        <div class="layui-input-block" >
                            <input th:id="${'value_' + section.index}" th:name="${'value_' + section.index}"
                                   th:value="${section.value}" class="layui-input" type="text" style="width:82%;float: left" />
                            <button th:onclick="|delSection(${section.index})|" class="layui-form-label" style="float: left">删除</button>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div style="text-align: center;margin-top: 20px">
                        <label onclick="addSection()" class="layui-btn layui-btn-normal">添加项</label>
                        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" th:src="@{/js/appjs/module/survey/question/detail.js}"></script>
</body>
</html>
